﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Payment_AgainstBill.aspx.cs"
    Inherits="Main_Inventory_Payment_AgainstBill" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Register Src="~/User Controls/PageHeading.ascx" TagName="heading" TagPrefix="acc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../../Styles/accounts.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        function isNumberKey(control_id, evt) {
            var charCode = (evt.which) ? evt.which : event.keyCode
            if (charCode > 31 && (charCode < 48 || charCode > 57) && (charCode < 45 || charCode >= 47))
                return false;
            if (charCode == 46) {
                var dotcount = document.getElementById(control_id).value.split('.').length - 1;
                if (dotcount >= 1) {
                    return false;
                }
            }
            return true;
        }
        function CheckValidAmt(id) {
            var lastNo = GetLastNumber(id.toString());
            var Amount = document.getElementById("txtAmount" + lastNo).value;
            var RecieptAmt = document.getElementById("txtRecievedAmt").value;
            var DdlTypeValue = document.getElementById("ddlType" + lastNo).value;
            var ddlParticulars = document.getElementById("ddlParticulars" + lastNo).value;
            var orignalamount = document.getElementById("txtOriginalAmt" + lastNo).value;
            if (Amount == '') {
                Amount = 0;
            }

            if (orignalamount == '') {
                orignalamount = 0;

            }


            if (document.getElementById("ddlvendor").value == '') {
                alert('Please Spaecify Vendor!');
                document.getElementById("ddlvendor").focus();
                document.getElementById(id).value = "0.00";
                flag = false;
            }
            else if (DdlTypeValue == '0') {
                alert('Please Select Type!');
                document.getElementById(id).value = "0.00";
                document.getElementById("ddlType" + lastNo).focus();
                flag = false;
            }
            else if (RecieptAmt == '' || parseFloat(RecieptAmt) == 0) {
                alert('Please Specify Reciept Amount!');
                document.getElementById(id).value = "0.00";
                document.getElementById("txtRecievedAmt").focus();
                flag = false;
            }
            else {
                var Total = parseFloat(parseFloat(Amount));
                if (DdlTypeValue == '2') {
                    if (ddlParticulars == '' || ddlParticulars == '0') {
                        alert('Please Specify Particulars!');
                        document.getElementById(id).value = "0.00";
                        document.getElementById("ddlParticulars" + lastNo).focus();
                    }
                    else {
                        if (parseFloat(Total) > parseFloat(orignalamount)) {
                            alert('Specified Amount Should not be\ngreater than Pending Amount');
                            document.getElementById(id).value = "0.00";
                        }
                    }
                }
            }

            Amount = document.getElementById("txtAmount" + lastNo).value;

            if (Amount == '') {
                Amount = 0;
            }

            Total = parseFloat(parseFloat(orignalamount) - parseFloat(Amount));

            if (DdlTypeValue == '2') {
                document.getElementById("txtPendingAfterRec" + lastNo).value = parseFloat(parseFloat(Total)).toFixed(2);
            }
            else {
                document.getElementById("txtPendingAfterRec" + lastNo).value = '0.00';
            }


            //-------- Calculate Grand Total-------------//
            var count = document.getElementById("hidRowCount").value;

            var TotalReceiptAmt = 0;


            var TotalPendingAmt = 0;
            for (var i = 1; i <= count; i++) {

                var ReceiptAmt = document.getElementById("txtAmount" + i).value;

                var PendingAmt = document.getElementById("txtPendingAfterRec" + i).value;

                if (ReceiptAmt == '') {
                    ReceiptAmt = 0;
                }


                if (PendingAmt == '') {
                    PendingAmt = 0;
                }
                TotalReceiptAmt += parseFloat(ReceiptAmt);
                TotalPendingAmt += parseFloat(PendingAmt);
            }
            document.getElementById("txtTotalReceipt").value = parseFloat(TotalReceiptAmt).toFixed(2); ;


            document.getElementById("txtTotalPending").value = parseFloat(TotalPendingAmt).toFixed(2);
            //--------End Calculate Grand Total-------------//
            return false;

        }
        function GetLastNumber(sText) {
            var Char;
            var lastRow = 0;
            for (i = 0; i < sText.length; i++) {
                Char = sText.charAt(i);
                if (!isNaN(parseFloat(Char))) {
                    lastRow = sText.toString().substr(i);
                    break;
                }
            }
            return lastRow;
        }

        function Validations() {
            var flag = true;
            if (document.getElementById("txtDate").value == '' || document.getElementById("txtDate").value == '__/__/____') {
                alert('Please Specify Receipt Date');
                document.getElementById("txtDate").focus();
                flag = false;
            }

            else if (document.getElementById("txtRecieptNumber").value == '') {
                alert('Please Specify Receipt Number ');
                document.getElementById("txtRecieptNumber").focus();
                flag = false;
            }

            else if (document.getElementById("ddlBank").value == '0' && parseFloat(document.getElementById("ddlRecieptMode").value) != 2) {
                alert('Please Specify Transaction Bank!');
                document.getElementById("ddlBank").focus();
                flag = false;
            }
            else if (document.getElementById("ddlvendor").value == '') {
                alert('Please Spaecify Party!');
                document.getElementById("ddlvendor").focus();
                flag = false;
            }

            else if (document.getElementById("ddlCurrency").value == '0') {
                alert('Please Specify Currency!');
                document.getElementById("ddlCurrency").focus();
                flag = false;
            }
            else if (document.getElementById("txtExchangeRate").value == '') {
                alert('Please Spaecify Exchange Rate !');
                document.getElementById("txtExchangeRate").focus();
                flag = false;
            }
            else if (document.getElementById("txtRecievedAmt").value == '') {
                alert('Please Specify Receipt Amount');
                document.getElementById("txtRecievedAmt").focus();
                flag = false;
            }
            return flag;
        }

        function ValdateDetails() {
            var flag = Validations();
            if (flag == true) {
                var count = document.getElementById("hidRowCount").value;
                var RecieptAmt = document.getElementById("txtRecievedAmt").value;
                var TotalAmount = 0;
                if (RecieptAmt == '') {
                    RecieptAmt = 0;
                }

                for (var i = 1; i <= count; i++) {
                    var Amount = document.getElementById("txtAmount" + i).value;
                    var DdlTypeValue = document.getElementById("ddlType" + i).value;
                    var ddlParticulars = document.getElementById("ddlParticulars" + i).value;
                    var Total = document.getElementById("txtAmount" + i).value;
                    if (Amount == '') {
                        Amount = 0;
                    }
                    if (Total == '') {
                        Total = 0;
                    }
                    TotalAmount += parseFloat(Amount);
                    if (parseFloat(Total) > 0 && DdlTypeValue == '0') {
                        alert('Specify Account type at row no ' + i);
                        flag = false;
                        break;

                    }
                    else if (DdlTypeValue != '0' && (ddlParticulars == '' && ddlParticulars == '0')) {
                        alert('Specify Particulars at row no ' + i);
                        flag = false;
                        break;
                    }
                    else if (DdlTypeValue != '0' && parseFloat(Total) == 0) {
                        alert('Specify Amount at row no ' + i);
                        flag = false;
                        break;
                    }
                }
                if (parseFloat(TotalAmount).toFixed(2) != parseFloat(RecieptAmt).toFixed(2)) {
                    alert('Entered Receipt amount not mached ');
                    flag = false;
                }
            }
            return flag;
        }


        function EnabledTabKey(id, e) {
            var keycode;
            if (window.event) {
                keycode = window.event.keyCode;
            }
            else if (e) {
                keycode = e.which;
            }
            else {
                return true;
            }

            if (keycode == 9) {
                // if is the tab key                
                return true;
            }
            else {
                return false;
            }
        }

        function ValidateRepeatParticulars(id) {

            var flag = true;
            var count = document.getElementById("hidRowCount").value;
            var CurrentParticulars = document.getElementById(id);
            var lastNo = GetLastNumber(id.toString());
            var currentValue = CurrentParticulars.options[CurrentParticulars.selectedIndex].value;

            for (var i = 1; i <= count; i++) {

                var PreviuosParticulars = document.getElementById("ddlParticulars" + i);
                var previousValue = PreviuosParticulars.options[PreviuosParticulars.selectedIndex].value;
                if (CurrentParticulars != PreviuosParticulars) {
                    if (currentValue == previousValue && previousValue != '0' && currentValue != '0') {
                        alert('Specified Particular can not be same');
                        CurrentParticulars.selectedIndex = '0';
                        document.getElementById("txtOriginalAmt" + lastNo).value = '';
                        document.getElementById("txtAmount" + lastNo).value = '';
                        document.getElementById("txtPendingAfterRec" + lastNo).value = '';
                        flag = false;
                        break;
                    }
                }
            }


            return flag;
        }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="scmanager" runat="server">
    </asp:ScriptManager>
    <acc:heading ID="pagehead" runat="server" HeadingText="Payment Receipt" />
    <div id="divmain" runat="server">
        <div style="width: 98%; margin-left: 25px; margin-top: 10px;">
            <div id="divmsg" runat="server" style="width: 85%; text-align: center; background-color: #dc143c;">
                <asp:Label ID="LblErrorMsg" runat="server" Font-Bold="true"></asp:Label>
            </div>
        </div>
        <asp:Panel ID="panelMain" runat="server" Width="100%">
            <div style="margin: 15px 0px 15px 25px; width: 95%;">
                <table width="100%">
                    <tr>
                        <td style="width: 90%">
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:HiddenField ID="hidBillingFromId" runat="server" />
                                    <asp:Label ID="lbl" runat="server"></asp:Label>
                                    <table width="100%" cellpadding="2" class="tablecontent" cellspacing="0" style="background-color: #FFFFFF">
                                        <tr>
                                            <td colspan="4" class="headtd">
                                                Payment
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; padding-top: 5px;">
                                                Date :
                                            </td>
                                            <td style="padding-top: 5px;">
                                                <asp:TextBox ID="txtDate" runat="server" CssClass="input" Width="150px"></asp:TextBox>
                                                <asp:ImageButton ID="imgDate" runat="server" ImageUrl="~/images/calendar.gif" />
                                                <ajax:CalendarExtender ID="calDate" runat="server" TargetControlID="txtDate" PopupButtonID="imgDate"
                                                    Format="dd/MM/yyyy">
                                                </ajax:CalendarExtender>
                                                <ajax:MaskedEditExtender ID="maskDate" runat="server" Mask="99/99/9999" MaskType="Date"
                                                    TargetControlID="txtDate" CultureName="en-GB">
                                                </ajax:MaskedEditExtender>
                                            </td>
                                            <td style="text-align: right">
                                                Bank :
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlBank" runat="server" CssClass="input" onclick="return CheckBillingCompany();"
                                                    Width="400px">
                                                </asp:DropDownList>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right">
                                                Payment Mode :
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlRecieptMode" runat="server" CssClass="input" Width="150px"
                                                    AutoPostBack="true">
                                                    <asp:ListItem Text="- - Payment Mode - -" Value="0"></asp:ListItem>
                                                    <asp:ListItem Text="Cheque" Value="1"></asp:ListItem>
                                                    <asp:ListItem Text="Cash" Value="2"></asp:ListItem>
                                                    <asp:ListItem Text="Credit/Debit Card" Value="3"></asp:ListItem>
                                                    <asp:ListItem Text="Net Banking" Value="4"></asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td style="text-align: right">
                                                Vendor:
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlvendor" runat="server" Width="400px" CssClass="input" AutoPostBack="true"
                                                    OnSelectedIndexChanged="ddlvendor_SelectedIndexChanged">
                                                </asp:DropDownList>
                                                <asp:HiddenField ID="hidvendorid" runat="server" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right">
                                                Payment Amount :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtRecievedAmt" runat="server" onkeypress="return isNumberKey(this.id,event);"
                                                    CssClass="input" Width="150px"></asp:TextBox>
                                            </td>
                                            <td style="text-align: right">
                                                Ref./Cheque No. :
                                            </td>
                                            <td>
                                                <table>
                                                    <tr>
                                                        <td>
                                                            <asp:TextBox ID="txtRefNo" runat="server" CssClass="input" Width="150px"></asp:TextBox>
                                                        </td>
                                                        <td>
                                                            Cheque/DD Date:
                                                        </td>
                                                        <td>
                                                            <asp:TextBox ID="txtChequeddDate" runat="server" CssClass="input" Width="90px"></asp:TextBox>
                                                            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/images/calendar.gif" />
                                                            <ajax:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtChequeddDate"
                                                                PopupButtonID="ImageButton1" Format="dd/MM/yyyy">
                                                            </ajax:CalendarExtender>                                                            
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right">
                                                Currency :
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlCurrency" runat="server" Width="150px" AutoPostBack="true"
                                                    CssClass="input" OnSelectedIndexChanged="ddlCurrency_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            </td>
                                            <td style="text-align: right">
                                                Exchange Rate :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtExchangeRate" runat="server" Text="1" onkeypress="return isNumberKey(this.id,event);"
                                                    CssClass="input" Width="150px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right; padding-top: 5px;">
                                                Payment No. :
                                            </td>
                                            <td style="padding-top: 5px;">
                                                <asp:TextBox ID="txtRecieptNumber" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"
                                                    Width="150px"></asp:TextBox>
                                            </td>
                                            <td style="text-align: right">
                                                Remarks :
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtRemarks" runat="server" CssClass="input" Width="400px"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: right">
                                            </td>
                                            <td>
                                            </td>
                                            <td>
                                            </td>
                                            <td>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                            <div style="background-color: #FFFFFF; width: 100%;">
                                &nbsp;
                            </div>
                            <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                <ContentTemplate>
                                    <asp:HiddenField ID="hidRowCount" runat="server" Value="2" />
                                    <table width="100%" cellpadding="2" id="tblDetails" cellspacing="0" style="background-color: #DEDBDE;"
                                        class="tablecontent" runat="server">
                                        <tr style="border-bottom: 1px solid #a5b5c6;">
                                            <td style="width: 15%; text-align: center; font-weight: bold;">
                                                Type
                                            </td>
                                            <td style="width: 15%; text-align: center; font-weight: bold;">
                                                Particulars
                                            </td>
                                            <td style="width: 12%; text-align: center; font-weight: bold;">
                                                Original Amt.
                                            </td>
                                            <%-- <td style="width: 12%; text-align: center; font-weight: bold;">
                                            Pending Amt.
                                        </td>--%>
                                            <td style="width: 12%; text-align: center; font-weight: bold;">
                                                Payment Amt.
                                            </td>
                                            <%--<td style="width: 12%; text-align: center; font-weight: bold;">
                                            Total
                                        </td>--%>
                                            <td style="width: 12%; text-align: center; font-weight: bold;">
                                                Pending after Payment
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:DropDownList ID="ddlType1" runat="server" OnSelectedIndexChanged="ddlType_SelectedIndexChanged"
                                                    AutoPostBack="true" Width="98%" CssClass="input">
                                                    <asp:ListItem Value="0">- - Select Type - -</asp:ListItem>
                                                    <asp:ListItem Value="1">On A/C</asp:ListItem>
                                                    <asp:ListItem Value="2">Towards Bill</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlParticulars1" Visible="false" AutoPostBack="true" runat="server"
                                                    OnSelectedIndexChanged="ddlParticulars_SelectedIndexChanged" CssClass="input"
                                                    Width="98%">
                                                </asp:DropDownList>
                                                <asp:TextBox ID="txtParticulars1" runat="server" CssClass="input" Width="98%"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtOriginalAmt1" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"
                                                    Width="98%"></asp:TextBox>
                                            </td>
                                            <%-- <td>
                                            <asp:TextBox ID="txtPendingAmt1" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"
                                                Width="98%"></asp:TextBox>
                                        </td>--%>
                                            <td>
                                                <asp:TextBox ID="txtAmount1" runat="server" onblur="return CheckValidAmt(this.id);"
                                                    onkeypress="return isNumberKey(this.id,event);" CssClass="input" Width="98%"></asp:TextBox>
                                            </td>
                                            <%--  <td>
                                            <asp:TextBox ID="txtTotalAmt1" runat="server" onkeydown="return EnabledTabKey(this.id,event);"
                                                CssClass="input" Width="98%"></asp:TextBox>
                                        </td>--%>
                                            <td>
                                                <asp:TextBox ID="txtPendingAfterRec1" runat="server" onkeydown="return EnabledTabKey(this.id,event);"
                                                    CssClass="input" Width="98%"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:DropDownList ID="ddlType2" runat="server" OnSelectedIndexChanged="ddlType_SelectedIndexChanged"
                                                    AutoPostBack="true" Width="98%" CssClass="input">
                                                    <asp:ListItem Value="0">- - Select Type - -</asp:ListItem>
                                                    <asp:ListItem Value="1">On A/C</asp:ListItem>
                                                    <asp:ListItem Value="2">Towards Bill</asp:ListItem>
                                                </asp:DropDownList>
                                            </td>
                                            <td>
                                                <asp:DropDownList ID="ddlParticulars2" Visible="false" OnSelectedIndexChanged="ddlParticulars_SelectedIndexChanged"
                                                    AutoPostBack="true" runat="server" CssClass="input" Width="98%" onchange="return ValidateRepeatParticulars(id);">
                                                </asp:DropDownList>
                                                <asp:TextBox ID="txtParticulars2" runat="server" CssClass="input" Width="98%"></asp:TextBox>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="txtOriginalAmt2" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"
                                                    Width="98%"></asp:TextBox>
                                            </td>
                                            <%-- <td>
                                            <asp:TextBox ID="txtPendingAmt2" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"
                                                Width="98%"></asp:TextBox>
                                        </td>--%>
                                            <td>
                                                <asp:TextBox ID="txtAmount2" runat="server" CssClass="input" onblur="return CheckValidAmt(this.id);"
                                                    onkeypress="return isNumberKey(this.id,event);" Width="98%"></asp:TextBox>
                                            </td>
                                            <%--  <td>
                                            <asp:TextBox ID="txtTotalAmt2" runat="server" onkeydown="return EnabledTabKey(this.id,event);"
                                               CssClass="input" Width="98%"></asp:TextBox>
                                        </td>--%>
                                            <td>
                                                <asp:TextBox ID="txtPendingAfterRec2" runat="server" onkeydown="return EnabledTabKey(this.id,event);"
                                                    CssClass="input" Width="98%"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                    <table width="100%" cellpadding="2" cellspacing="0" style="background: white">
                                        <tr>
                                            <td style="width: 50%; padding-right: 20px; font-weight: bold;">
                                                <asp:ImageButton ID="btnAddMoreRow" runat="server" alt="Add New Row" ImageUrl="../../Images/More.jpg"
                                                    OnClick="btnAddMoreRow_Click" />
                                            </td>
                                            <td align="right" style="width: 13%; padding-right: 20px; font-weight: bold;">
                                                Total
                                            </td>
                                            <td style="width: 18.5%;">
                                                <asp:TextBox ID="txtTotalReceipt" Width="99%" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"></asp:TextBox>
                                            </td>
                                            <%-- <td style="width: 12%;">
                                            <asp:TextBox ID="txtGrandTotal" runat="server" Width="98%" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"></asp:TextBox>
                                        </td>--%>
                                            <td style="width: 18.5%;">
                                                <asp:TextBox ID="txtTotalPending" Width="99%" runat="server" CssClass="input" onkeydown="return EnabledTabKey(this.id,event);"></asp:TextBox>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                        <td valign="top" style="width: 10%">
                            <table cellpadding="2" cellspacing="0" style="background-color: White;">
                                <tr>
                                    <td>
                                        <asp:Button ID="btnsubmit" runat="server" Text="Save" CssClass="button1" Width="70px"
                                            OnClick="btnsubmit_Click" OnClientClick="return FormValidation();" />
                                        <script type="text/javascript">
                                            function FormValidation() {
                                                if (document.getElementById("txtDate").value == "") {
                                                    alert("Please Enter the Date Of Payment.");
                                                    document.getElementById("txtDate").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlBank").selectedIndex == 0) {
                                                    alert("Please Select the Bank Name.");
                                                    document.getElementById("ddlBank").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlRecieptMode").selectedIndex == 0) {
                                                    alert("Please Select Payment Mode.");
                                                    document.getElementById("ddlRecieptMode").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlvendor").selectedIndex == 0) {
                                                    alert("Please Select the Vendor.");
                                                    document.getElementById("ddlvendor").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtRecievedAmt").value == "") {
                                                    alert("Please Enter the Payment Amount.");
                                                    document.getElementById("txtRecievedAmt").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtRefNo").value == "") {
                                                    alert("Please Enter the Reference/Cheque No");
                                                    document.getElementById("txtRefNo").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlCurrency").selectedIndex == 0) {
                                                    alert("Please Select the Currency.");
                                                    document.getElementById("ddlCurrency").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtExchangeRate").value == "") {
                                                    alert("Please Enter the Exchange Rate.");
                                                    document.getElementById("txtExchangeRate").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtRecieptNumber").value == "") {
                                                    alert("Please Enter the  Payment Number.");
                                                    document.getElementById("txtRecieptNumber").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("txtRemarks").value == "") {
                                                    alert("Please Enter the Remarks.");
                                                    document.getElementById("txtRemarks").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlType1").selectedIndex == 0) {
                                                    alert("Please Select the Type at Row [1].");
                                                    document.getElementById("ddlType1").focus();
                                                    return false;
                                                }
                                                if (document.getElementById("ddlType1").selectedIndex == 1) {
                                                    if (document.getElementById("txtParticulars1").value == "") {
                                                        alert("Please Enter the Particulars at Row [1].");
                                                        document.getElementById("txtParticulars1").focus();
                                                        return false;
                                                    }
                                                }
                                                if (document.getElementById("ddlType1").selectedIndex == 2) {
                                                    if (document.getElementById("ddlParticulars1").selectedIndex == 0) {
                                                        alert("Please Select the Particulars at Row [1].");
                                                        document.getElementById("ddlParticulars1").focus();
                                                        return false;
                                                    }
                                                }
                                                if (document.getElementById("txtAmount1").value == "" || document.getElementById("txtAmount1").value == '0') {
                                                    alert("Please Enter the Payment Amount at Row [1].");
                                                    document.getElementById("txtAmount1").focus();
                                                    return false;
                                                }
                                            }
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:Button ID="btncancel" runat="server" Text="Cancel" CssClass="button1" Width="70px" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </div>
        </asp:Panel>
    </div>
    </form>
</body>
</html>
